﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    [Serializable]
    [DataContract]
    public class Emp_Duty
    {
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        private int _EmpBasicID;
        [DataMember]
        public int EmpBasicID
        {
            get { return _EmpBasicID; }
            set { _EmpBasicID = value; }
        }

        private string _DutyNo = string.Empty;
        [DataMember]
        public string DutyNo
        {
            get { return _DutyNo; }
            set { _DutyNo = value; }
        }

        private string _DutyName = string.Empty;
        [DataMember]
        public string DutyName
        {
            get { return _DutyName; }
            set { _DutyName = value; }
        }

        private string _DutyLevel = string.Empty;
        [DataMember]
        public string DutyLevel
        {
            get { return _DutyLevel; }
            set { _DutyLevel = value; }
        }

        private string _DutyAttribute = string.Empty;
        [DataMember]
        public string DutyAttribute
        {
            get { return _DutyAttribute; }
            set { _DutyAttribute = value; }
        }

        private DateTime? _OKDate = null;
        [DataMember]
        public DateTime? OKDate
        {
            get { return _OKDate; }
            set { _OKDate = value; }
        }

        private string _OrganizationName = string.Empty;
        [DataMember]
        public string OrganizationName
        {
            get { return _OrganizationName; }
            set { _OrganizationName = value; }
        }

        private string _Sec = string.Empty;
        [DataMember]
        public string Sec
        {
            get { return _Sec; }
            set { _Sec = value; }
        }

        private string _WorkCharge = string.Empty;
        [DataMember]
        public string WorkCharge
        {
            get { return _WorkCharge; }
            set { _WorkCharge = value; }
        }

        private string _ServiceMode = string.Empty;
        [DataMember]
        public string ServiceMode
        {
            get { return _ServiceMode; }
            set { _ServiceMode = value; }
        }

        private string _IsExceptionalPromotion = string.Empty;
        [DataMember]
        public string IsExceptionalPromotion
        {
            get { return _IsExceptionalPromotion; }
            set { _IsExceptionalPromotion = value; }
        }

        private string _JobStatus = string.Empty;
        [DataMember]
        public string JobStatus
        {
            get { return _JobStatus; }
            set { _JobStatus = value; }
        }

        private DateTime? _JobDate = null;
        [DataMember]
        public DateTime? JobDate
        {
            get { return _JobDate; }
            set { _JobDate = value; }
        }

        private string _EmpName = string.Empty;
        [DataMember]
        public string EmpName
        {
            get { return _EmpName; }
            set { _EmpName = value; }
        }

        private string _EmpNo = string.Empty;
        [DataMember]
        public string EmpNo
        {
            get { return _EmpNo; }
            set { _EmpNo = value; }
        }

        private int _RenQi = 0;
        [DataMember]
        public int RenQi
        {
            get { return _RenQi; }
            set { _RenQi = value; }
        }

        private int _RZSYQ = 0;
        [DataMember]
        public int RZSYQ
        {
            get { return _RZSYQ; }
            set { _RZSYQ = value; }
        }

        private DateTime? _BRZDQRQ = null;
        [DataMember]
        public DateTime? BRZDQRQ
        {
            get { return _BRZDQRQ; }
            set { _BRZDQRQ = value; }
        }

        private string _LianRen = string.Empty;
        [DataMember]
        public string LianRen
        {
            get { return _LianRen; }
            set { _LianRen = value; }
        }

        private DateTime? _RXRZWSXSJ = null;
        [DataMember]
        public DateTime? RXRZWSXSJ
        {
            get { return _RXRZWSXSJ; }
            set { _RXRZWSXSJ = value; }
        }

        private DateTime? _GRStartDate = null;
        [DataMember]
        public DateTime? GRStartDate
        {
            get { return _GRStartDate; }
            set { _GRStartDate = value; }
        }

        private DateTime? _GREndDate = null;
        [DataMember]
        public DateTime? GREndDate
        {
            get { return _GREndDate; }
            set { _GREndDate = value; }
        }

        public static Emp_Duty FillEntity(DataRow dr)
        {
            Emp_Duty right = new Emp_Duty();
            right.ID = (int)dr["ID"];
            right.EmpBasicID = (int)dr["EmpBasicID"];
            right.DutyNo = dr["DutyNo"] as string;
            right.DutyName = dr["DutyName"] as string;
            right.DutyLevel = dr["DutyLevel"] as string;
            right.EmpName = dr["EmpName"] as string;
            right.EmpNo = dr["EmpNo"] as string;
            right.DutyAttribute = dr["DutyAttribute"] as string;
            right.OrganizationName = dr["OrganizationName"] as string;
            right.Sec = dr["Sec"] as string;
            right.WorkCharge = dr["WorkCharge"] as string;
            right.ServiceMode = dr["ServiceMode"] as string;
            right.IsExceptionalPromotion = dr["IsExceptionalPromotion"] as string;
            right.JobStatus = dr["JobStatus"] as string;
            right.OKDate = (string.IsNullOrEmpty(dr["OKDate"].ToString()) || dr["OKDate"].ToString() == "1900/1/1 0:00:00" || Convert.ToDateTime(dr["OKDate"]) == Convert.ToDateTime("1900-1-1")) ? null : (DateTime?)dr["OKDate"];
            right.JobDate = (string.IsNullOrEmpty(dr["JobDate"].ToString()) || dr["JobDate"].ToString() == "1900/1/1 0:00:00" || Convert.ToDateTime(dr["JobDate"]) == Convert.ToDateTime("1900-1-1")) ? null : (DateTime?)dr["JobDate"];

            if (dr.Table != null && dr.Table.Columns.Contains("RenQi")) if (!string.IsNullOrEmpty(dr["RenQi"].ToString())) right.RenQi = Convert.ToInt32(dr["RenQi"].ToString());
            if (dr.Table != null && dr.Table.Columns.Contains("RZSYQ")) if (!string.IsNullOrEmpty(dr["RZSYQ"].ToString())) right.RZSYQ = Convert.ToInt32(dr["RZSYQ"].ToString());
            if (dr.Table != null && dr.Table.Columns.Contains("BRZDQRQ"))
                right.BRZDQRQ = (string.IsNullOrEmpty(dr["BRZDQRQ"].ToString()) || dr["BRZDQRQ"].ToString() == "1900/1/1 0:00:00" || Convert.ToDateTime(dr["BRZDQRQ"]) == Convert.ToDateTime("1900-1-1")) ? null : (DateTime?)dr["BRZDQRQ"];
            if (dr.Table != null && dr.Table.Columns.Contains("LianRen")) if (!string.IsNullOrEmpty(dr["LianRen"].ToString())) right.LianRen = dr["LianRen"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("RXRZWSXSJ"))
                right.RXRZWSXSJ = (string.IsNullOrEmpty(dr["RXRZWSXSJ"].ToString()) || dr["RXRZWSXSJ"].ToString() == "1900/1/1 0:00:00" || Convert.ToDateTime(dr["RXRZWSXSJ"]) == Convert.ToDateTime("1900-1-1")) ? null : (DateTime?)dr["RXRZWSXSJ"];

            if (dr.Table != null && dr.Table.Columns.Contains("GRStartDate"))
                right.GRStartDate = (string.IsNullOrEmpty(dr["GRStartDate"].ToString()) || dr["GRStartDate"].ToString() == "1900/1/1 0:00:00" || Convert.ToDateTime(dr["GRStartDate"]) == Convert.ToDateTime("1900-1-1")) ? null : (DateTime?)dr["GRStartDate"];
            if (dr.Table != null && dr.Table.Columns.Contains("GREndDate"))
                right.GREndDate = (string.IsNullOrEmpty(dr["GREndDate"].ToString()) || dr["GREndDate"].ToString() == "1900/1/1 0:00:00" || Convert.ToDateTime(dr["GREndDate"]) == Convert.ToDateTime("1900-1-1")) ? null : (DateTime?)dr["GREndDate"];
            return right;
        }
    }
}
